package com.example.study.ui.view

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Card
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.bianque.studyhavecompose.R
import com.bianque.studyhavecompose.ui.theme.CFFFFFF
import com.bianque.studyhavecompose.ui.theme.Purple200
import com.bianque.studyhavecompose.ui.theme.Purple700

import org.jetbrains.annotations.NotNull



@OptIn(ExperimentalFoundationApi::class)
@Composable
fun ToolItemView(
    @NotNull text: String = "",
    modifier: Modifier = Modifier,
    height: Dp = 25.dp,
    onClick: (() -> Unit)
) {

    Card(backgroundColor = Purple200){
        Row(
            Modifier
                .padding(start = 8.dp, end = 8.dp)
                .fillMaxWidth()
                .clip(shape = RoundedCornerShape(12.dp))
                .background(Purple700)
            ,
            verticalAlignment = Alignment.CenterVertically,
        ) {
            Text(
                text = text,
                modifier = modifier
                    .height(height)
                    .padding(
                        horizontal = 10.dp,
                        vertical = 3.dp
                    )
                    .combinedClickable(
                        onClick = {
                            onClick?.invoke()
                        }
                    )
                    .weight(1f, true),
                    //.background(Teal200),
                fontSize = 14.sp,
                textAlign = TextAlign.Left,
                color = CFFFFFF,
                //overflow = TextOverflow.Ellipsis,
                //maxLines = 1,
                //onClick = onClick?.invoke(),

            )
            Image(
                painter = painterResource(id = R.mipmap.yuanshi),
                contentDescription = null,
                Modifier.size(16.dp)
            )
        }
    }

}

